/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pbl_cliente;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Scanner;

/**
 * @author Tayane
 */
public class EnviaMsgMulticast {
    
    private static  int porta = 5000;
    private static String grupo = "225.4.5.6";
    private String msg;
    
    public EnviaMsgMulticast(int portaMlticast, String ipMulticast, String msg){
        
    }
    
    public void exe()throws UnknownHostException, IOException{
     
        while(true)  {
            Scanner sc  = new Scanner(System.in);
            msg = sc.nextLine();

           // msg = "To akiiii!!!!";
            DatagramSocket s = new DatagramSocket();
            byte buf[] = msg.getBytes();

      //      for(int i=0;i< buf.length;i++){
      //          buf[i] = (byte)i;
      //      }

            DatagramPacket pack = new DatagramPacket(buf,buf.length,InetAddress.getByName(grupo),porta);

            s.send(pack);
        }
  }
}
